﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.BLL;

namespace ClassLibrary.DAL
{
    public class DALDonHang
    {
        public static List<BLLDonHang> GetAll()
        {
            var dhs = from dh in DALCommon.NonDB.PhieuXuats
                     select
                     new BLLDonHang(dh.IDPX,dh.MaPX,dh.TenPX,Convert.ToDateTime(dh.NgayXuat),Convert.ToDecimal(dh.TongTien),Convert.ToInt32(dh.IDKhach));
            return dhs.ToList<BLLDonHang>();
        }
        public static List<BLLDonHang> GetChiTietDH(BLLDonHang donhang )
        {
            var dhs = from dh in DALCommon.NonDB.PhieuXuats
                      where dh.IDPX==donhang.ID
                      select
                      new BLLDonHang(dh.IDPX, dh.MaPX, dh.TenPX, Convert.ToDateTime(dh.NgayXuat), Convert.ToDecimal(dh.TongTien), Convert.ToInt32(dh.IDKhach),new DALKhachHang().GetByID(donhang.IDKhach));
            return dhs.ToList<BLLDonHang>();
        }
    }
}
